import json

list = []
jsonDB = {}

with open(r'C:\Users\firex\Desktop\生字表\小学一至六年级生字表.txt', 'r', encoding='utf-8') as f1:
    list = f1.readlines()

for i in range(int(len(list)/2)):
    k = list[i*2].strip()
    j0 = {}
    j1 = {}
    j2 = {}
    j3 = {}
    jsonDB[k] = {'0': j0, '1': j1, '2': j2, '3': j3}
    for c in list[i * 2 + 1].strip():
        j0[c] = 0

with open(r'C:\Users\firex\Desktop\生字表\小学一至六年级生字表.json', 'w', encoding='utf-8') as f2:
    json.dump(jsonDB, f2, sort_keys=False, ensure_ascii=False)

